package document.controller;


import document.dao.DocumentDao;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Map;

public class toViewCheckResultServlet extends HttpServlet {
    private final DocumentDao documentDao = new DocumentDao();
    private static final long serialVersionUID = 1;

    public toViewCheckResultServlet() {
        super();
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws IOException, ServletException {
        doPost(request, response);
    }

    /**
     * 返回文档审核意见页面
     * @param request
     * @param response
     * @throws IOException
     * @throws ServletException
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws IOException, ServletException {
        System.out.println("进入了toViewCheckResultServlet");
        Map<String, Object> map = documentDao.findCheckResultById(Integer.parseInt(request.getParameter("id")));
        System.out.println(map);
        request.setAttribute("review",map.get("review"));
        request.setAttribute("score",map.get("score"));
        request.setAttribute("document_id",map.get("document_id"));
        request.getRequestDispatcher("/view/document/document-check.jsp").forward(request,response);
    }
}
